package entities {
	import org.flixel.FlxObject;
	import org.flixel.FlxSprite;
	import org.flixel.plugin.photonstorm.FlxDelay;
	
	
	public class MeleeAttack extends FlxSprite {
		public var _parent:Player;
		public var damages:Number;
		
		
		public function MeleeAttack() {
			super(0, 0, Registry.blankPNG);
			
			var delay:FlxDelay = new FlxDelay(500);
			delay.callback = attackCallback;
			delay.start();
			
			active = false;
		}
		
		public function attack():void{
			if(_parent) _parent._attacking = true;
			Registry.friendlyPool.add(this);
			
		}
		
		public function setParent(Parent:Player):void{
			this._parent = Parent;
			width =  _parent.width+_parent.width/2;
			height = _parent.height * 2 / 3;
			
			x = (_parent.facing == RIGHT) ? _parent.x+width/2 : _parent.x-width/2;
			y = _parent.y + _parent.height/4;
		}
		
		private function attackCallback():void {
			Registry.friendlyPool.remove(this,true);
			_parent._attacking = false;
			kill();
		}
	}
}
